package club.janna.springboot.study.service;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.sql.DataSource;

@Service
public class UserService {

    private JdbcTemplate jdbcTemplate;

    public void setDataSource(DataSource dataSource) {
        jdbcTemplate = new JdbcTemplate(dataSource);
    }

    public String getUsername() {
        return "Janna";
    }

    @Transactional
    public void save() {
        jdbcTemplate.update("insert into user values(?, ?, ?, ?)", 19L, "gg", "gg", "gg");
        int i = 1 / 0;
    }
}
